﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace yule.CodeBuilder.Controllers
{

    /// <summary>
    /// 控制器基类
    /// (执行操作的Action以Do开头)
    /// </summary>
    public class BaseController : Controller
    {

        private yule.Util.RunTime rt = null;

        /// <summary>
        /// 方法执行开始
        /// </summary>
        /// <param name="filterContext"></param>
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);
            rt = new yule.Util.RunTime();
        }

        /// <summary>
        /// 方法执行结束
        /// </summary>
        /// <param name="filterContext"></param>
        protected override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            if (rt != null)
            {
                yule.Common.LogManager.Write(filterContext.ActionDescriptor.ActionName + ":" + rt.GetTotal() + "毫秒", Common.Log.Level.Debug);
            }
            base.OnActionExecuted(filterContext);
        }



        /// <summary>
        /// 服务容器
        /// </summary>
        protected yule.Common.WCF.ServiceContext ServiceContext
        {
            get
            {
                return yule.Common.ServiceManager.ServiceContext;
            }
        }

    }
}